#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

//    QPushButton* PB = new QPushButton(this);
//    //建立链接
//    connect(PB, &QPushButton::clicked, this, &Widget::MySlots);
//    //断开链接
//    disconnect(PB, &QPushButton::clicked, this, &Widget::MySlots);

//    QPushButton* PB = new QPushButton("关闭", this);
//    connect(PB, &QPushButton::clicked, this, [=](){
//        this->close();
//    });

    // 按钮点击时打印参数
    QPushButton *btn = new QPushButton("测试", this);
    connect(btn, &QPushButton::clicked, [=](bool checked) {
        qDebug() << "按钮是否被选中：" << checked;
    });
}

Widget::~Widget()
{
    delete ui;
}

void Widget::MySlots()
{
    qDebug() << "触发信号";
}


